jQuery(function($) {
    $("#email").keyup(email_list);//自动补全
    
    $("#div_a>a").click(div_a_tab);//TAB页联动
    $("#ul_tab>li>a").click(ul_a_tab);//类别联动


});


/**
 * 自动补全
 * @returns {undefined}
 */
function email_list() {
    var email_value = $(this).val();
    var email_index = email_value.indexOf("@");
    if (-1 !== email_index) {
        email_value = email_value.substring(0, email_index);
    }
    var email_list = new Array();
    email_list.push("<option label = " + email_value + "@qq.com value = " + email_value + "@qq.com />");
    email_list.push("<option label = " + email_value + "@163.com value = " + email_value + "@163.com />");
    email_list.push("<option label = " + email_value + "@gmail.com value = " + email_value + "@gmail.com />");
    email_list.push("<option label = " + email_value + "@outlook.com value = " + email_value + "@outlook.com />");
    $("#email_list").empty();
    $("#email_list").append(email_list.join(""));
    $("#email").focus();
}
/**
 * TAB页联动
 * @returns {undefined}
 */
function div_a_tab() {
    var obj = $(this);
    obj.parent("div").children("a").removeClass("active");
    obj.addClass("active");
    var a_name = obj.attr("data-name");
    $("#ul_tab a[href=#" + a_name + "]").tab('show');
}

/**
 * 类别联动
 * @returns {undefined}
 */
function ul_a_tab() {
    var a_name = $(this).attr("href").substr(1);
    var obj = $("a[data-name=" + a_name + "]");
    obj.parent("div").children("a").removeClass("active");
    obj.addClass("active");
}